//*****************************************************************************
//
// Copyright, (C) 2000-2005 Quantic Dream SA
//
// These coded instructions, statements and computer programs contain
// unpublished information, proprietary to Quantic Dream SA and are 
// protected by French and EEC copyright laws. They may not be 
// disclosed to third parties or copied or duplicated, in whole or in part, 
// without prior written consent of Quantic Dream SA
//
// Unpublished-rights reserved under the Copyright Laws of the EEC.
//
//*****************************************************************************
//
//	CLASS:	MESH_INSTANCE
//
//	JJA : 2012-07-23 - Created
//*****************************************************************************

#include	"MeshInstance.h"
#include	"Mesh.h"
#include	"Shaders\Shader.h"

//=============================================================================
//	CODE STARTS HERE
//=============================================================================

//-----------------------------------------------------------------------------
//! @brief		MESH_INSTANCE constructor
//! @details		
//! @param		
//! @return		
//! @author		JJA : 2012-07-23
//-----------------------------------------------------------------------------
MESH_INSTANCE::MESH_INSTANCE(const MESH *	pMesh)
: _pMesh	( pMesh )
, _pShader	( NULL )
{
	
}

//-----------------------------------------------------------------------------
//! @brief		MESH_INSTANCE destructor
//! @details		
//! @param		
//! @return		
//! @author		JJA : 2012-07-23
//-----------------------------------------------------------------------------
MESH_INSTANCE::~MESH_INSTANCE()
{
	
}

//-----------------------------------------------------------------------------
//! @brief		SetShader
//! @details		
//! @param		
//! @return		
//! @author		JJA : 2012-07-26
//-----------------------------------------------------------------------------
void	MESH_INSTANCE::SetShader(const SHADER *	pShader)
{
	_pShader = pShader;
}

//-----------------------------------------------------------------------------
//! @brief		GetShader
//! @details		
//! @param		
//! @return		
//! @author		JJA : 2012-07-26
//-----------------------------------------------------------------------------
const SHADER *	MESH_INSTANCE::GetShader() const
{
	return	( _pShader );
}

//-----------------------------------------------------------------------------
//! @brief		Draw
//! @details		
//! @param		
//! @return		
//! @author		JJA : 2012-07-26
//-----------------------------------------------------------------------------
void	MESH_INSTANCE::Draw(CAMERA *	pCamera)
{
	// Bind the static mesh
	_pMesh->Bind();

	// Start using the shader
	_pShader->Begin();

	// Apply the shader to the mesh instance using the specified camera
	_pShader->Apply( this, pCamera );

	// Draw the mesh
	_pMesh->Draw();

	// End using the shader
	_pShader->End();

	// Unbind the static mesh
	_pMesh->Unbind();
}

//=============================================================================
//	CODE ENDS HERE
//=============================================================================
